# # 四个数字的和
# def sum_of_four_numbers(a, b, c, d):
#     return a + b + c + d
#
# # 从键盘接收四个数字
# num1 = float(input("请输入第一个数字："))
# num2 = float(input("请输入第二个数字："))
# num3 = float(input("请输入第三个数字："))
# num4 = float(input("请输入第四个数字："))
#
# # 调用方法并打印结果
# result = sum_of_four_numbers(num1, num2, num3, num4)
# print("四个数字的和是：", result)

#***********************************************************************************

# 列表求和
# def sum_of_list(numbers):
#     return sum(numbers)
#
# # 输入一个数字列表
# input_list = input("请输入一个数字列表，用逗号分隔：")
# #处理传入的字符串，将其转换为数字列表
# numbers_list = [float(item)
#                 for item in input_list.split(',')]
# # 调用方法并打印结果
# total_sum = sum_of_list(numbers_list)
# print("列表的总和是：", total_sum)

#**************************************************************************************

# 打印99乘法表的方法
# def print_multiplication_table():
#     for i in range(1, 10):
#         for j in range(1, i + 1):
#             #f-string格式化输出,{}占位符
#             print(f"{j} * {i} = {i * j}", end="\t")
#         print()
# print_multiplication_table()
#

# **************************************************************************************
# 该方法参数是一个列表和一个索引，返回列表中对应索引的元素，如果索引超出范围，则返回-1
# def get_element_by_index(data_list, index):
#     if 0 <= index < len(data_list):
#         return data_list[index]
#     else:
#         return -1
#
# my_list = [10, 20, 30, 40, 50]
#
# index_to_find = 2
# result = get_element_by_index(my_list, index_to_find)
# print("传入的索引是: ",index_to_find)
# print(f"元素是: {result}")
#
# index_to_not_find = 10
# resulta= get_element_by_index(my_list, index_to_not_find)
# print("传入的索引是: ",index_to_not_find)
# print(f"超出范围的元素是: {resulta}")

# **************************************************************************************

# 求1到300所有数的和
# def sum_of_numbers(n):
#     if n == 1:
#         return 1
#     else:
#         return n + sum_of_numbers(n - 1)
#
# # 调用方法，求1到300所有数的和
# result = sum_of_numbers(300)
# print(f"1到300所有数的和是: {result}")

# **************************************************************************************

# #1.求部门员工总共有多少人
# test_dept={"xiaoming","xiaozhang","xiaohuang","xiaoyang"}
# dev_dept={"xiaohuang","xiaoli","xiaowang","xiaoyang","xiaozhou"}
# sol_dept={"xiaoyang","xiaozhang","xiaowu","xiaofeng","xiaozhou"}
#
# sum_people=test_dept|dev_dept|sol_dept
# print(f"部门员工总共有{len(sum_people)}人")
#
# #2.求只在一个部门存在的人的数量和对应的名字
#
# only_test = test_dept - (dev_dept | sol_dept)
# only_dev = dev_dept - (test_dept | sol_dept)
# only_sol = sol_dept - (test_dept | dev_dept)
#
# only_dept = only_test | only_dev | only_sol
#
# print("只在一个部门存在的人的数量和对应的名字：",len(only_dept))
# for name in only_dept:
#     print(name,end=" ")
#
# #3.在两个部门以及以上的人员有哪些
#
# in_test_and_dev = test_dept & dev_dept
# in_test_and_sol = test_dept & sol_dept
# in_dev_and_sol = dev_dept & sol_dept
#
# in_two_or_more_dept = in_test_and_dev | in_test_and_sol | in_dev_and_sol
# print("在两个部门以及以上的人员有：",len(in_two_or_more_dept))
# for name in in_two_or_more_dept:
#     print(name)

#倒序打印乘法表
# 定义函数，打印NxN的乘法表的倒叙
# def reverse_multiplication_table(N):
#     for i in range(N, 0, -1):
#         for j in range(i
#                 , 0, -1):
#             print(f"{i} * {j} = {i * j}", end="\t")
#         print()
#
# N = 5
# reverse_multiplication_table(N)








